package com.lfnyxy.service.imp;

import com.lfnyxy.dao.RecruitDao;
import com.lfnyxy.entity.RecruitEntity;
import com.lfnyxy.query.RecruitQuery;
import com.lfnyxy.service.RecruitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecruitServiceImp implements RecruitService {
    @Autowired
    public RecruitDao recruitDao;

    public int CreateItem(RecruitEntity entity) {
        if (entity != null) {
            return recruitDao.CreateItem(entity);
        } else {
            return 0;
        }
    }

    public int UpdateItem(RecruitEntity entity) {
        if (entity != null) {
            return recruitDao.UpdateItem(entity);
        } else {
            return 0;
        }
    }

    public List <RecruitEntity> QueryPageList(RecruitQuery query) {
        int count = recruitDao.QueryPageListCount(query);
        query.setTotal(count);
        return recruitDao.QueryPageList(query);
    }

    public List <RecruitEntity> QueryAll() {
        return recruitDao.QueryAll();
    }

    public RecruitEntity QueryItem(int Id) {
        if (Id > 0) {
            return recruitDao.QueryItem(Id);
        } else {
            return null;
        }
    }

    public int DeleteItem(int Id) {
        if (Id > 0) {
            return recruitDao.DeleteItem(Id);
        } else {
            return 0;
        }
    }

    private boolean CheckIsExist(RecruitEntity entity) {
        if (entity != null) {
            return recruitDao.CheckIsExist(entity) > 0;
        } else {
            return false;
        }
    }
}